package logic

import (
	"context"
	"shopexam/shoprpc/shoprpc"

	"shopexam/api/internal/svc"
	"shopexam/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShopLikeLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewShopLikeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShopLikeLogic {
	return &ShopLikeLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ShopLikeLogic) ShopLike(req *types.ShopLikeRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	like, err := l.svcCtx.ShopRpc.ShopLike(l.ctx, &shoprpc.ShopLikeRequest{Id: int64(req.ShopId)})
	if err != nil {
		return &types.Response{
			Msg:  "收藏失败" + err.Error(),
			Code: 500,
			Data: nil,
		}, nil
	}
	return &types.Response{
		Msg:  "收藏成功",
		Code: 200,
		Data: like,
	}, nil
}
